<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>jquery template demo</title>
  </head>

  <body>
    <!-- 2、骨架结构 -->
    <table cellspacing="0" cellpadding="3" border="1">
      <tbody id="rows"></tbody>
    </table>

    <!-- 3、定义模板（注意type类型） -->
    <script id="myTemplate" type="text/x-jquery-tmpl">
      <tr>
        <td>${id}</td>
        <td>${name}</td>
      </tr>
    </script>

    <!-- 1、引入文件 -->
    <script
      type="text/javascript"
      src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"
    ></script>
    <script type="text/javascript" src="./9/jquery.tmpl.min.js"></script>
    <!-- 4、将数据渲染到模板； -->
    <script>
      $(function () {
        var users = [
          { id: 'think8848', name: 'Joseph Chan' },
          { id: 'aCloud', name: 'Mary Cheung' },
        ]
        $('#myTemplate').tmpl(users).appendTo('#rows')
      })
    </script>
  </body>
</html>
